<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head th:include="include :: header"></head>
<body class="gray-bg">

<div class="container-div">
    <div class="row">
        <div class="col-sm-12 select-info">
            <form id="operlog-form">
                <div class="select-list gd">
                    <ul>

                        <li class="select-time">
                            <label>创建时间： </label>
                            <input type="text" class="time-input" style="width: 150px" id="beginTime" placeholder="开始时间"
                                   name="beginTime" lay-key="1">
                            <span>-</span>
                            <input type="text" class="time-input" style="width: 150px" id="overTime" placeholder="结束时间"
                                   name="overTime" lay-key="2">
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm"
                               onclick="$.table.search($('form').attr('id'))"><i class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm"
                               onclick="$.form.reset($('form').attr('id'))"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group hidden-xs" id="toolbar" role="group">

            <a class="btn btn-outline btn-success btn-rounded" onclick="$.operate.add()" shiro:hasPermission="workTime:add">
                <i class="fa fa-plus"></i> 新增
            </a>
            <a class="btn btn-outline btn-danger btn-rounded" onclick="$.operate.batRemove()"
               shiro:hasPermission="workTime:del">
                <i class="fa fa-trash-o"></i> 删除
            </a>
        </div>

        <div class="col-sm-12 select-info order-table">
            <table id="bootstrap-table" data-mobile-responsive="true"></table>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:src="@{/ajax/libs/select/select2.js}"></script>
<script th:inline="javascript">
    var updateFlag = [[${@permission.hasPermi('workTime:update')}]];
    var delFlag = [[${@permission.hasPermi('workTime:del')}]];
    var prefix = "/worktime";
    $(function () {
        var options = {
            url: prefix + "/tableList",
            createUrl: prefix + "/toAdd",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/del",
            sortName: "id",
            sortOrder: 'asc',
            modalName: "日程工作",
            search: false,
            showExport: false,
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '编号',
                },
                {
                    field: 'attendMorStartTime',
                    title: '早打卡时间范围',
                    visible: true,
                    formatter:function (value,row) {
                        return $.common.dateFormatGetTimeSort(value)+"-" +$.common.dateFormatGetTimeSort(row.attendMorendTime);
                    }
                },
                {
                    field: 'workStartTimeMor',
                    title: '早上工作时间',
                    formatter:function (value,row) {
                        return $.common.dateFormatGetTimeSort(value)+"-" +$.common.dateFormatGetTimeSort(row.attendMorendTime);
                    }
                },
                {
                    field: 'attendMorLeaveStartTime',
                    title: '早上下班打卡时间',
                    formatter:function (value,row) {
                        return $.common.dateFormatGetTimeSort(value)+"-"+ $.common.dateFormatGetTimeSort(row.attendMorLeaveEndTime);
                    }
                },
                {
                    field: 'attendAfterNoonStartTime',
                    title: '下午上班打卡时间',
                    formatter:function (value,row) {
                        return $.common.dateFormatGetTimeSort(value)+"-"+ $.common.dateFormatGetTimeSort(row.attendAfterNoonendTime)
                    }
                },
                {
                    field: 'workStartTimeAfterNoon',
                    title: '下午工作时间',
                    formatter:function (value,row) {
                        return $.common.dateFormatGetTimeSort(value)+"-"+ $.common.dateFormatGetTimeSort(row.workEndTimeAfterNoon);
                    }
                },
                {
                    field: 'attendAfterLeaveStartTime',
                    title: '下午下班打卡时间',
                    formatter:function (value,row) {
                        return $.common.dateFormatGetTimeSort(value)+"-" +$.common.dateFormatGetTimeSort(row.attendAfterLeaveEndTime);
                    }
                },
                {
                  field:'createTime',
                  title:'创建时间',
                    formatter:function (value,row) {
                        return $.common.dateFormat(value);
                    }
                },
                {
                    field: 'status',
                    title: '类型',
                    formatter: function (value) {
                        if (value==0) {
                            return '<span class="badge badge-primary">启用</span>';
                        }else if (value==1) {
                            return '<span class="badge badge-warning">停用</span>';
                        }
                    }
                },

                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-primary btn-xs '+updateFlag+'" onclick="update(\'' + row.id + '\',\''+0+'\')"><i class="fa fa-play"></i>启用</a> ');
                        actions.push('<a class="btn btn-success btn-xs '+updateFlag+'" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs '+delFlag+'"   onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };

        $.table.init(options);
    });

    function update(id,status){
        $.ajaxSettings.async=true;
        $.post("/worktime/updateStatus/",{id:id,status:status},function (data) {
            $.operate.ajaxSuccess(data)
        }).error(function (data) {
            $.modal.alertError("系统错误！");
        })
    }
</script>
</body>
</html>